import Vue from 'vue'
import Router from 'vue-router'
import City from '@/pages/city/City'
import Detail from '@/detail/Detail'
import CheckAll from '@/checkall/checkall'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: () => import('@/pages/home/Home')
    }, {
      path: '/city',
      name: 'City',
      component: City
    }, {
      path: '/detail/:id',
      name: 'Detail',
      component: Detail
    }, {
      path: '/checkall',
      name: 'CheckAll',
      component: CheckAll
    }
  ],
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})

Router.beforeEach((to, next, next) => {
  const nextRoute = ['home', 'good-list', 'good-detail', 'cart', 'profile'];//路由白名单
  let isLogin = global.isLogin;  // 是否登录
  if(nextRoute.indexOf(to.name) >= 0) { //通过下标来获取是否是在白名单内

  }
})
